# Makefile for altbit
#
# NOTE: Because dynamic DOORS libraries are used, the library path must
#       exist in LD_LIBRARY_PATH which can be used in adding extra library
#       directories. For example:
#
#       tcsh: setenv LD_LIBRARY_PATH /share/faster/doors/install/lib
#       bash: export LD_LIBRARY_PATH=/share/faster/doors/install/lib
#       zsh: Who cares?
 
DOORS = /share/faster/doors
CXX = g++
DOORS_INCLUDES = -I/share/faster/doors/include
DOORS_LIBS = -L/share/faster/doors/lib -ldoors_tools -ldoors_protocols -ldoors_base
CXXFLAGS = -g $(DOORS_INCLUDES)
COAPCLIENTOBJS = coappdu.o coapclientsap.o coapclientsm.o coapclienttask.o coapclient.o options.o
COAPSERVEROBJS = coappdu.o coapserversap.o coapserversm.o coapservertask.o coapserver.o options.o


all: client server

client: $(COAPCLIENTOBJS)
	$(CXX) $(CXXFLAGS) -o coapClient $(COAPCLIENTOBJS) $(DOORS_LIBS)

server: $(COAPSERVEROBJS)
	$(CXX) $(CXXFLAGS) -o coapServer $(COAPSERVEROBJS) $(DOORS_LIBS)

#options.cpp: options:h

coapclient.cpp: coapclienttask.h
coapserver.cpp: coapservertask.h

coapclienttask.cpp: coapclienttask.h
coapclienttask.h: coapclientsm.h coappdu.h coapclientsap.h

coapservertask.cpp: coapservertask.h
coapservertask.h: coapserversm.h coappdu.h coapserversap.h

coapclientsap.cpp: coapclientsap.h
coapclientsap.h: coapclient.sap
	$(DOORS)/bin/dsapg --hh-file coapclientsap.h --cc-file coapclientsap.cpp coapclient.sap

coapserversap.cpp: coapserversap.h
coapserversap.h: coapserver.sap
	$(DOORS)/bin/dsapg --hh-file coapserversap.h --cc-file coapserversap.cpp coapserver.sap

coapclientsm.cpp: coapclientsm.h
coapclientsm.h: coapclient.sm
	$(DOORS)/bin/dsmg --hh-file coapclientsm.h --cc-file coapclientsm.cpp coapclient.sm

coapserversm.cpp: coapserversm.h
coapserversm.h: coapserver.sm
	$(DOORS)/bin/dsmg --hh-file coapserversm.h --cc-file coapserversm.cpp coapserver.sm

coappdu.cpp: coappdu.h options.h
coappdu.h: coap.pdu options.h
	$(DOORS)/bin/dpeerg --hh-file coappdu.h --i-file coappdu.i coap.pdu

clean:
	rm -rf *.o coapserversm.h coapserversm.cpp coapclientsm.h coapclientsm.cpp coappdu.h coappdu.i coapclientsap.h coapclientsap.cpp \
	coapserversap.h coapserversap.cpp coapClient coapServer *~

